package org.example.gateway.utils;

import org.springframework.core.io.ClassPathResource;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class FileUtil {
    public static String readFile(String fileName) throws IOException {
        StringBuilder text = new StringBuilder();
        File file = new ClassPathResource(fileName).getFile();
        FileReader fileReader = new FileReader(file);
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        String line;
        while ((line=bufferedReader.readLine())!=null) {
            text.append(line);
            text.append("\n");
        }

        bufferedReader.close();
        return text.toString();
    }
}
